package library.operation;

import library.Book;
import library.BookList;

import java.util.Scanner;

//还书
public class ReturnOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("借书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要借书籍的序号：");
        int index = scanner.nextInt();
        if (index < 0 || index >= bookList.getSize()) {
            System.out.println("输入的选项非法");
            return;
        }
        Book book = bookList.getBook(index);
        if (book.getBorrowed() == false) {
            System.out.println("该书籍未被借出!!!");
        }
        book.setBorrowed(false);
        System.out.println("还书成功。");
    }
}
